<script type="text/javascript">
		$(document).ready(function(){
			//điền slug
			$("#title").focusout(function(){
				$("#slug").attr("value",getSlug($(this).attr("value")));
			});

			//check valid submit
			$("#submit").click(function(){
				var msg = "";
				var txtTitle = $("#title").attr("value");
				var slcCategory = $("#category_id").attr("value");
				if(txtTitle == ""){
					msg+= "Thiếu tiêu đề trang!\n";
				}
				if(slcCategory == 0){
					msg += "Chưa chọn chuyên mục cho trang.";
				}
				if(msg != ""){
					alert(msg);
					return false;
				}
				
			});
		});
</script>
<div id="r-heading">
	<img src="<?php echo PUBLIC_URL.'/admin/images/article.png';?>" alt=""/>
	<span>Tạo trang mới</span>
</div>
<?php
	//nếu có message thì hiển thị
	if(!empty($this->message)){
		echo '<div id="message">'.$this->message.'</div>';
	} 
?>
<form id="frmCreateArticle" class="" enctype="application/x-www-form-urlencoded" action="" method="post">
	<div class="r-left" style="width:70%; float:left;">

			<div class="row">
				<label for="title" class="required">Tiêu đề:</label>
				<input class="text" type="text" name="title" id="title" value="" size="50" />
			</div>
			<div class="row">
				<label for="\summary">Tóm tắt:</label>
				<textarea name="summary" rows="24" cols="80"></textarea>
			</div>
			
			<div class="row">
				<label for="slug" class="required">Slug (tên hiển thị trên URL):</label>
				<input type="text" name="slug" id="slug" value="" size="30" />
			</div>
			<div class="row">
				<label for="category_id">Chuyên mục:</label>
				<select name="category_id" id="category_id">
					<option value="0">Lựa chọn một chuyên mục</option>
					<?php
					foreach ($this->arrCategories as $category){
						echo "<option value='".$category->id."'>".$category->name."</option>";
					}
					?>
				</select>
				
			</div>
			<div class="row">
				<label for="tag">Tiêu đề của trang (thẻ title):</label>
				<input type="text" name="page_title" id="page_title" value="" size="50" />
			</div>
			<div class="row">
				<label for="tag">Miêu tả của trang (thẻ description):</label>
				<input type="text" name="page_description" id="page_description" value="" size="50" />
			</div>
			<div class="row">
				<label for="tag">Điền tag cho trang (thẻ keyword):</label>
				<input type="text" name="tag" id="tag" value="" size="30" />
			</div>
			<div class="row content">
				<label for="content" class="required">Nội dung:</label>
				<textarea name="content" id="content"></textarea>
			</div>
	
	
	</div>
	<div class="r-right" style="width:25%;float:right;">
		<div class="row" style="width:100%; clear: both;">
					<label style="width:100%; clear: both;" for="feature_image" class="optional">Ảnh đại diện:</label>
					<input type="hidden" name="feature_image"  id="feature_image" value="" />
					<img src="<?php echo PUBLIC_URL."/admin/images/article_default.jpg";?>" width="100%" id="imgFeature" alt="Ảnh đại diện"/>
					<button name="btnSelectImage" id="btnSelectImage" class="button" type="button" onclick="BrowseServer();">Chọn ảnh</button>
				</div>
		<div class="row" style="width:100%; clear: both;">
				<input class="button" type="submit" name="submit" id="submit" value="Lưu" />
				<input class="button" type="reset" name="reset" id="reset" value="Làm lại" />
			</div>
	</div>
	<script type="text/javascript">
		CKEDITOR.replace("content");
		
		function BrowseServer()
		{

			// You can use the "CKFinder" class to render CKFinder in a page:
			var finder = new CKFinder() ;
			finder.basePath = '<?php echo PUBLIC_URL."/ckfinder/";?>' ;	// The path for the installation of CKFinder (default = "/ckfinder/").
			
			finder.selectActionFunction = function(fileUrl){
				
				document.getElementById( "feature_image" ).value = fileUrl ;
				document.getElementById( 'imgFeature' ).src = fileUrl;
				
			}
			finder.popup() ;

			
		}
		
	</script>

</form>
